package com.stargate.soft.scenario;

import java.sql.SQLException;

import com.stargate.bd.ConnectionBD;
import com.stargate.bd.dao.factory.PointAccesBatimentDAO;
import com.stargate.exception.UnSeulPointAccesBatimentException;

public class SuppressionPointAccesBatiment {

	public SuppressionPointAccesBatiment(String codePointAcces) throws SQLException,
			UnSeulPointAccesBatimentException {
		// transaction Serializable
		ConnectionBD.setSerializable();

		try {
			PointAccesBatimentDAO pointAccesBatimentDAO = new PointAccesBatimentDAO();
			pointAccesBatimentDAO.delete(codePointAcces);
		} catch (SQLException e) {
			if (e.getErrorCode() == UnSeulPointAccesBatimentException.ERROR_CODE) {
				throw new UnSeulPointAccesBatimentException(e.getMessage());
			} else {
				throw e;
			}
		}
		
		// commit
		ConnectionBD.commit();
	}

}
